package com.ucode.application.controller.crm;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ucode.application.form.crm.FollowupRecordForm;
import com.ucode.crm.service.BusinessStatusGroupService;
import com.ucode.tool.base.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@Api(tags="跟进记录")
@RestController
@RequestMapping("/cms-followupRecord")
@Validated
public class FollowupRecordController {
    
    @Autowired
    private BusinessStatusGroupService businessStatusGroupService;

    @PreAuthorize("hasAuthority('sys:dataRole:read') or hasRole('ADMIN')")
    @ApiOperation("默认列表")
    @GetMapping(value = "/list")
    public ResponseResult<Object> list(
            @ApiParam(value ="日期")  @RequestParam(value = "ss") Date ss,
            @ApiParam(value="页码",example="1") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @ApiParam(value="每页记录数",example="5") @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize){
        
        
        return ResponseResult.success();
    }
    
    @PreAuthorize("hasAuthority('sys:dataRole:write') or hasRole('ADMIN')")
    @ApiOperation(value="创建")
    @PostMapping("/create")
    public ResponseResult<Object> sendTextMsg(@Validated @RequestBody FollowupRecordForm form) {
 
        return ResponseResult.success();
    }
    

  
    
    @PreAuthorize("hasAuthority('sys:dataRole:write') or hasRole('ADMIN')")
    @ApiOperation(value="删除")
    @ApiImplicitParam(name = "id", value = "商机状态组ID", required = true, dataType = "String",paramType = "path")
    @PostMapping("/delete/{id}")
    public ResponseResult<Object> delete(@PathVariable(name="id",required=true) Long id) {
        
        //校验是否有商机正在使用
        
        int i = businessStatusGroupService.deleteByLogic(id);
        return i > 0 ? ResponseResult.success() : ResponseResult.failed();
    }
 
    
}
